#pragma once
#include"hash.h"
namespace my_unordered_set
{
	template<class K, class Hash = HashFunc<K>>
	class unordered_set
	{
		struct SetKeyOfT
		{
			K operator()(const K& key)
			{
				return key;
			}
		};
	public:
		typedef typename HashBucket<K, const K, SetKeyOfT, Hash>::iterator iterator;
		typedef typename HashBucket<K, const K, SetKeyOfT, Hash>::const_iterator const_iterator;

		iterator begin()
		{
			return _h.begin();
		}

		iterator end()
		{
			return _h.end();
		}

		const_iterator begin() const
		{
			return _h.begin();
		}

		const_iterator end() const
		{
			return _h.end();
		}
		pair<iterator,bool> insert(const K& key)
		{
			return _h.Insert(key);
		}

		void erase(const K& key)
		{
			_h.Erase(key);
		}

	private:
		HashBucket<K, const K, SetKeyOfT, Hash> _h;
	};

	template<class K>
	void Print(const unordered_set<K>& s)
	{
		for (auto& e : s)
		{
			cout << e << " ";
		}
		cout << endl;
	}

	void test_unordered_set()
	{
		unordered_set<int> s;
		s.insert(31);
		s.insert(11);
		s.insert(5);
		s.insert(15);
		s.insert(25);
		s.erase(31);
		//for (auto& e : s)
		//{
		//	cout << e << " ";
		//}
		//cout << endl;
		Print(s);
	}
}
